﻿using Localization.Resources.AbpUi;
using Himp.Platform.Localization;
using Volo.Abp.Account;
using Volo.Abp.FeatureManagement;
using Volo.Abp.Identity;
using Volo.Abp.Localization;
using Volo.Abp.Modularity;
using Volo.Abp.PermissionManagement.HttpApi;
using Volo.Abp.SettingManagement;
using Volo.Abp.TenantManagement;
using Himp.Outpatient;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Http.Client;
using Himp.DataHub;
using Himp.Setl;
using Himp.Erp;

namespace Himp.Platform;

[DependsOn(
    typeof(PlatformApplicationContractsModule),
    typeof(AbpAccountHttpApiModule),
    typeof(AbpIdentityHttpApiModule),
    typeof(AbpPermissionManagementHttpApiModule),
    typeof(AbpTenantManagementHttpApiModule),
    typeof(AbpFeatureManagementHttpApiModule),
    typeof(AbpSettingManagementHttpApiModule),
    typeof(OutpatientHttpApiClientModule),
    typeof(DataHubHttpApiClientModule),
    typeof(SetlHttpApiClientModule),
    typeof(ErpHttpApiClientModule),
    typeof(AbpHttpClientModule)
    )]
public class PlatformHttpApiModule : AbpModule
{
    public override void ConfigureServices(ServiceConfigurationContext context)
    {
        ConfigureLocalization();

        context.Services.AddHttpClientProxies(
            typeof(OutpatientApplicationContractsModule).Assembly,
            remoteServiceConfigurationName: "Outpatient");
        context.Services.AddHttpClientProxies(
            typeof(DataHubApplicationContractsModule).Assembly,
            remoteServiceConfigurationName: "DataHub");
        context.Services.AddHttpClientProxies(
            typeof(SetlApplicationContractsModule).Assembly,
            remoteServiceConfigurationName: "Setl");
        context.Services.AddHttpClientProxies(
            typeof(ErpApplicationContractsModule).Assembly,
            remoteServiceConfigurationName: "Erp");
    }


    private void ConfigureLocalization()
    {
        Configure<AbpLocalizationOptions>(options =>
        {
            options.Resources
                .Get<PlatformResource>()
                .AddBaseTypes(
                    typeof(AbpUiResource)
                );
        });
    }
}
